home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / decky.arc / DECKEY.LIS next >
File List  |  1989-06-15  |  16KB  |  307 lines

  1. DECKeybd.doc                                               June, 1989
  2.   
  3. Introduction:
  4.  
  5. I'm typing this on a DEC LK201 keyboard connected to an Atari 1040ST
  6. through the midi port.  Now I won't have to get a Mega to have a
  7. decent, detachable, keyboard!  Besides, this keyboard has a better
  8. layout and ( IMHO ) feel than the one that comes with a Mega.  
  9.  
  10. One of reason that I started using ST's was that its keyboard layout is
  11. almost identical to a DEC keyboard.  Since my microcomputers spend a lot
  12. of time acting as terminals talking to VAX computer systems, the
  13. compatible keyboard layout is very important to me.  On the other hand,
  14. I have always hated the feel of  the ST keyboard.  I think it is the
  15. ST's worst feature.  Now I have been able to keep the layout and get
  16. much better feel in a detached keyboard.
  17.  
  18. LK201s keyboards are used on all current DEC products, including
  19. terminals and workstations. Moreover, they were used on the DEC Rainbow
  20. PC's and on the previous generation of DEC terminals.  As a result,
  21. they are fairly common at ham and computer fests. You could also get a
  22. new one from DEC as a replacement part, albeit for too much money!
  23.  
  24. The obvious choice for an external ST keyboard would be an extended PC
  25. keyboard.  Its layout is fairly close to the ST's, and it is relative
  26. cheap and very available.  Unfortuately, its electrical interface is
  27. quite incompatible with any of the Atari's ports. PC keyboard use with
  28. the ST would require a complicated external interface adapter.  I don't
  29. know if anyone has done it, but I decided it wasn't worth the trouble.
  30. On the other hand, the LK201 keyboard can be wired directly to either
  31. the serial or midi ports. 
  32.  
  33. LK201s conform to RS-423 standards at 4800 baud, 8 bits, no parity, one
  34. stop bit.  They send a single byte of code ( a scan code ) for most key
  35. presses, only the shift and control keys send codes on both down and
  36. up. When a key or keys is help down, a metronome ( repeat ) code is
  37. sent at a fixed rate.
  38.  
  39. The ST keyboards use a serial interface at 7.8125 K baud. They send a
  40. scan code when a key is depressed or released. The software require to
  41. convert input from the DEC keyboard to that used by the ST is straight
  42. forward.
  43.  
  44. If you are willing to use your serial port, no modifications to the ST
  45. or keyboard are required.  All it takes is a small, external, power
  46. supply and a RJ11 ( modular phone plug ) to DB25 adapter.  The
  47. limitation when using the serial port is that you can't use the ST as a
  48. terminal with the external keyboard.  The midi port interface doesn't
  49. have this limitation but it does require internal modifications to the
  50. ST.
  51.  
  52. The power supply requirement is 200ma. at 12 V.  The voltage is
  53. regulated internally so it isn't very critical.  A range from 10 V. to
  54. 15 V. seems OK, although you might have internal heat problems in the
  55. keyboard at the upper end of that range. Suitable wall transformer type
  56. supplies are available for less than $10.  Since I'm not going to buy a
  57. Mega ST, my ST's power supply will have to handle 4 megabytes of memory
  58. in the near future. I didn't want to further load the ST's already
  59. marginal power supply with the extra keyboard.  
  60.  
  61. The midi port problem is that its baud rate is is hardwired into the
  62. computer.  Changing the midi port's baud rate to 4800 baud is
  63. straightforward, but it should only be done by someone with good
  64. soldering skills and PC ( that's Printed Circuit, not Personal
  65. Computer!  ) experience.
  66.  
  67. The modification uses one TTL IC, half a dozen short pieces of wire,
  68. two solder connections to pins on existing IC's and one trace cut on
  69. the top of the ST circuit board.  It isn't even necessary to remove the
  70. metal shield on a 1040 ST, because everything you need to get at is
  71. located under the disk drive.  Since this change will affect the
  72. operation of the midi port, you may wish to mount a switch ( SPDT )
  73. that selects either 4800 or the normal ( 31.25K )baud rate.
  74.  
  75. No external keyboard, unless it is simply an ST keyboard mounted in a
  76. separate case, can replace the built in keyboard.  STs need the
  77. mouse, joystick, and clock functions of the original keyboard.  An
  78. external keyboard must simply work in parallel with the original
  79. keyboard.
  80.  
  81. Software:
  82.  
  83. When you strike a key on the ST's keyboard, a scancode is sent from it
  84. to a serial port on the main board.  This causes the serial port to
  85. generate an interrupt.  The interrupt is serviced by a routine that:
  86.  
  87.         1. Gets the scan code sent by the keyboard
  88.         2. Determines wether it is dealing with
  89.            regular keys, shift keys or the mouse
  90.         3. Performs the appropriate function.
  91.  
  92. As a result of a regular key press, the scancode and an ascii code  
  93. ( looked up in a set of tables ) are placed in a queue.  Shift codes
  94. ( right shift, left shift, control, caps lock, and alternate ) simply
  95. cause a change the contents of a flag byte.  The contents of this byte
  96. determine which of three tables is used for looking up the scan code
  97. and if control or ALT are used as modifiers.
  98.  
  99. An external keyboard must duplicate, as much as is possible, these
  100. regular key and shift functions and not disrupt the other ( mouse,
  101. clock, and joystick ) keyboard functions.  Since the builtin keyboard
  102. functions involve modification of data structures ( keyboard queue and
  103. shift byte ) in memory, the external keyboard software can simply
  104. modify the same data structures.  If the keyboard software was not
  105. interrupt driven with these intermediate data stuctures, it would be
  106. much more dificult to add an external keyboard.
  107.  
  108. The serial port, the keyboard port, and the midi port all use similar
  109. interfaces.  This makes it easy to write an interrupt handler for the
  110. serial or midi port that duplicate the  services provide by keyboard
  111. port interrupt handler.  Most of the needed subroutines are already in
  112. the ST's ROMs.  The code needed to add a keyboard is quite small, about
  113. 700 bytes. I'm sending uuencoded sources and binaries to
  114. comp.{sources|binaries}. atari.st.
  115.  
  116. Bugs/Differences from the ST keyboard:
  117.  
  118. Well this an 'alpha' release, so it probably has a few unintended
  119. 'features'!  On the other hand, it is a small, simple, and straight
  120. forward program.  I have been using the midi version for several weeks
  121. on a 1040 ST and a friend has been using the serial port version on a
  122. 520 ST for two weeks.  We haven't found any problems.
  123.  
  124. I did have trouble when I tried using the external keyboard to replace
  125. my mouse buttons.  I had to eliminate that 'feature' since it regularly
  126. crashed the ST! The serial version won't work with a screen blanker
  127. that monitors the keyboard/midi interrupt vector since it doesn't use
  128. that vector!  The midi version works with idle 1.2, but it must be run
  129. before idle is run.
  130.  
  131. I didn't put a lot of effort into handling the alt key because I very
  132. rarely use it.  On the LK201, the alt key says 'Compose Character' and,
  133. because of the way I handled it, it only affects the next key pressed. 
  134. The only program I use that has a problem with alt is Uniterm.
  135. Unfortunately I use Uniterm more than any other program ( thank you
  136. Simon Poole!  ).  Uniterm doesn't use the normal alt flag, so I just do
  137. the Uniterm alt stuff from my regular keyboard.
  138.  
  139. The LK201 keyboard is programmable, but I have not made any use of this
  140. feature.  The midi interface is only 'RS423 compatible' for input, so
  141. extra hardware would be required there.  The serial interface should be
  142. able to talk to the keyboard, but I had no luck in my limited attempts
  143. to do so.  Since I am comfortable with the keyboards default settings,
  144. I made my interface input only.
  145.  
  146. Now let's consider the keyboard remappings: There is only one shift
  147. code, so there is no way to set only one of two shift bits.  I don't
  148. have any programs that distinguish between the the two shift keys,
  149. but you may.  It can't be done with the DEC keyboard.  Another DEC
  150. limitation, DEC keyboards don't have a backspace key or an escape
  151. key in the main keypad.  I 'fixed' both these problems.
  152.  
  153. Delete is the key where backspace was and shift-delete acts as
  154. backspace.  This works well when I use the ST as a terminal and with
  155. emacs like editors.  Since some ST programs use backspace as delete
  156. left, I also put bac